package com.lwj.liwanjia.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lwj.liwanjia.R;
import com.lwj.liwanjia.bean.MySpBean;
import com.lwj.liwanjia.utils.BaseUtils;

import java.util.List;

/**
 * Created by 001 on 2017/9/13.
 */

public class WoDeJiLuHomeAdapter extends RecyclerView.Adapter<WoDeJiLuHomeAdapter.ViewHolder> {

    private Context mContext;
    private List<MySpBean.DataBean> mList;

    public WoDeJiLuHomeAdapter(Context mContext,List<MySpBean.DataBean> mList) {
        this.mContext = mContext;
        this.mList = mList;

    }

    @Override
    public WoDeJiLuHomeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.adapter_wo_de_ji_lv_home, parent, false);

        ViewHolder holder = new ViewHolder(view);

        return holder;
    }

    @Override
    public void onBindViewHolder(WoDeJiLuHomeAdapter.ViewHolder holder, int position) {

        MySpBean.DataBean bean = mList.get(position);

        long time = bean.getTime();
        String timeResult = BaseUtils.getString(String.valueOf(time / 1000));
        holder.tv_time.setText(timeResult);
        holder.tv_content.setText(bean.getCommodityName());

    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        TextView tv_time;
        TextView tv_content;

        public ViewHolder(View itemView) {
            super(itemView);

            tv_time = (TextView) itemView.findViewById(R.id.tv_time);
            tv_content = (TextView) itemView.findViewById(R.id.tv_content);
        }
    }
}
